<?php
namespace c\auth;
\lang::load('user');

/**
 * Description of group
 *
 * @author YeFng
 */
class group extends \m\base_ad
{
    var $auth_m = 'auth\group';
    var $table = 'au_group';
    var $t_p = 'auth/group';
    var $title = 'Permission Group';
    
    function save($data, $id=NULL)
    {
        $data['module_ids'] = intval_ids($data['module_ids']);
        return parent::save($data, $id);
    }
    function home()
    {
        $tables = array('t1'=>array('as'=>$this->table), 'user'=>array('join'=>'LEFT JOIN','on'=>'FIND_IN_SET(t1.id, user.`au_group_ids`)'));
        $res =  $this->db->group('t1.id')->get($tables, 'count(user.id) userNum, t1.*');
		return $res;
    }
}
